//
// Created by HeiBai on 2020/6/13.
//

#ifndef NDK_PLAYER_CODE_MYPLAYER_H
#define NDK_PLAYER_CODE_MYPLAYER_H

#include <cstring>
#include <pthread.h>
#include "AudioChannel.h"
#include "VideoChannel.h"
#include "JNICallback.h"
#include <android/log.h>

extern "C" {
#include <libavformat/avformat.h>
}


class MyPlayer {
public:
    MyPlayer();


    MyPlayer(const char *string, JNICallback *pCallback);

//析构函数
    virtual ~MyPlayer();

    void prepare();

    void prepare_();

    void start();

    void start_();
    void setRenderCallback(RenderCallback renderCallback);

private:
    char *data_source = 0;
    pthread_t pid_prepare = 0;
    AVFormatContext *avFormatContext;//媒体的总上下文
    AudioChannel *audioChannel = 0;
    VideoChannel *videoChannel = 0;
    JNICallback *jniCallback=0; //JNI回调
    bool isPlayer=1; //是否播放的标记
    pthread_t pid_start=0;
    RenderCallback  renderCallback;
};



#endif